<template>
	<view>
		<view class="goods-item" >
			<view class="goods-item-left">
				<radio :checked="goods.goods_state" color="#C00000" v-if="showRadio" @click="radioChangeHandler"></radio>
				<image :src="goods.goods_small_logo"></image>
			</view>
			<view class="goods-item-right">
				<view class="goods-title">{{goods.goods_name}}</view>
				<view class="goods-info-box">
					<view class="goods-price">￥{{tofixFilter(goods.goods_price)}}</view>
					<uni-number-box v-if="showNum" :min="1" :value="goods.goods_count" @change="numChangeHandler"></uni-number-box>
				</view>
				
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"my-goods",
		props:{
			goods:{
				type:Object
			},
			showRadio:{
				type:Boolean,
				default:false
			},
			showNum:{
				type:Boolean,
				default:false
			}
		},
		data() {
			return {
				
			};
		},
		methods:{
			tofixFilter(price){
				console.log(price)
				return Number(price).toFixed(2)
			},
			radioChangeHandler(){
				this.$emit('radio-change',{
					goods_id:this.goods.goods_id,
					goods_state:!this.goods.goods_state
				})
			},
			numChangeHandler(val){
				this.$emit('num-change',{
					goods_id:this.goods.goods_id,
					goods_count:+val
				})
			}
		}
	}
</script>

<style lang="scss">
.goods-item{
	width: 750rpx;
	box-sizing: border-box;
		display: flex;
		padding: 10px 0;
		border-bottom: 1px solid #f0f0f0;
		
		.goods-item-left{
			display: flex;
			justify-content: space-between;
			align-items: center;
			image{
				display: block;
				width: 160rpx;
				height: 160rpx;
			}
		}
		.goods-item-right{
			display: flex;
			flex: 1;
			flex-direction: column;
			justify-content: space-between;
			margin-left: 15rpx;
			.goods-title{
				font-size: 12px;
			}
			.goods-info-box{
				display: flex;
				justify-content: space-between;
				align-items: center;
				.goods-price{
					color: #C00000;
					font-size: 16px;
				}
			}
			
		}
	}
</style>